<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>测试div</title>
    <style>
        #test {
            height: 200px;
            width: 100px;
            position: relative;
            border: solid 1px red;
            overflow-y: auto;
        }
    </style>
</head>
<body>
<div id="test">

</div>
<button onclick="add()">go</button>
<textarea name="" id="" cols="30" rows="10"></textarea>
<script>

    function add() {
        var test = document.getElementById('test')
        test.innerHTML = test.innerHTML + "<br>123"
        test.scrollTop = test.scrollHeight
    }
</script>
</body>
</html>